﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace THenu.TinyHourseLib.DesignPattern.Creational_Patterns.Builder_Pattern
{
    class Product
    {
        public List<String> _Parts = new List<string>();

        public void Add(string part)
        {
            _Parts.Add(part);
        }

        public void Show()
        {
            Console.WriteLine("\nProduct Parts -------");
            foreach (string part in _Parts)
                Console.WriteLine(part);
        }
    }
    abstract class AbsBuilder
    {
        public abstract void BuildPartA();
        public abstract void BuildPartB();
        public abstract Product GetResult();
    }
    /// <summary>
    /// The 'ConcreteBuilder' class
    /// </summary>
    class ConcreteBuilder1 : AbsBuilder
    {
        private Product _product = new Product();
        public override void BuildPartA()
        {
            _product.Add("Part A");
        }

        public override void BuildPartB()
        {
            _product.Add("Part B");
        }

        public override Product GetResult()
        {
            return _product;
        }
    }
    /// <summary>
    /// The 'ConcreteBuilder' class
    /// </summary>
    class ConcreteBuilder2 : AbsBuilder
    {
        private Product _product = new Product();
        public override void BuildPartA()
        {
            _product.Add("Part X");
        }

        public override void BuildPartB()
        {
            _product.Add("Part Y");
        }

        public override Product GetResult()
        {
            return _product;
        }
    }
    /// <summary>
    /// The 'Director' class
    /// </summary>
    class Director
    {
        // Builder uses a complex series of steps
        public void Construct(AbsBuilder builder)
        {
            builder.BuildPartA();
            builder.BuildPartB();
        }
    }
}
